; generated by Component: ARM Compiler 5.05 (build 41) Tool: ArmCC [4d0eb9]
; commandline ArmCC [--thumb --list --debug -c --asm --interleave -o.\obj\timer.o --asm_dir=.\Obj\ --list_dir=.\Obj\ --depend=.\obj\timer.d --apcs=interwork -O0 -IC:\Keil\ARM\RV31\INC -IC:\Keil\ARM\CMSIS\Include -IC:\Keil\ARM\Inc\Philips --omf_browse=.\obj\timer.crf timer\timer.c]
                          THUMB

                          AREA ||.text||, CODE, READONLY, ALIGN=2

                  Timer_init PROC
;;;21     // initialize timer 0 to count milliseconds
;;;22     void Timer_init(void) {
000000  2000              MOVS     r0,#0
;;;23       // use timer 0 as timer (pclk = 12MHz)
;;;24       T0CTCR = 0x00;
000002  4921              LDR      r1,|L1.136|
000004  6308              STR      r0,[r1,#0x30]
;;;25       // prescaler - count at 1kHz
;;;26       T0PR = 12000-1;
000006  4821              LDR      r0,|L1.140|
000008  491f              LDR      r1,|L1.136|
00000a  3940              SUBS     r1,r1,#0x40
00000c  60c8              STR      r0,[r1,#0xc]
;;;27       // no matches or interrupts
;;;28       T0MCR = 0x0000;
00000e  2000              MOVS     r0,#0
000010  6148              STR      r0,[r1,#0x14]
;;;29       // enable
;;;30       T0TCR = 0x01;
000012  2001              MOVS     r0,#1
000014  6048              STR      r0,[r1,#4]
;;;31     }
000016  4770              BX       lr
;;;32     
                          ENDP

                  Timer_DeInit PROC
;;;35     // the state of the registers
;;;36     void Timer_DeInit(void) {
000018  2000              MOVS     r0,#0
;;;37       // disable
;;;38       T0TCR  = 0x00;
00001a  491b              LDR      r1,|L1.136|
00001c  3940              SUBS     r1,r1,#0x40
00001e  6048              STR      r0,[r1,#4]
;;;39       T0CTCR = 0x00;
000020  4919              LDR      r1,|L1.136|
000022  6308              STR      r0,[r1,#0x30]
;;;40       T0PR   = 0;
000024  4918              LDR      r1,|L1.136|
000026  3940              SUBS     r1,r1,#0x40
000028  60c8              STR      r0,[r1,#0xc]
;;;41       T0MCR  = 0x0000;
00002a  6148              STR      r0,[r1,#0x14]
;;;42       T0TC   = 0;
00002c  6088              STR      r0,[r1,#8]
;;;43       T0PC   = 0;
00002e  6108              STR      r0,[r1,#0x10]
;;;44     }
000030  4770              BX       lr
;;;45     
                          ENDP

                  Timer_GetTimestamp PROC
;;;46     // get the current timer 0 count
;;;47     unsigned long Timer_GetTimestamp(void) {
000032  4815              LDR      r0,|L1.136|
;;;48       return T0TC;
000034  3840              SUBS     r0,r0,#0x40
000036  6880              LDR      r0,[r0,#8]
;;;49     }
000038  4770              BX       lr
;;;50     
                          ENDP

                  Timer_HasTimestampExpired PROC
;;;52     // returns 1 if in the past, 0 if not
;;;53     int Timer_HasTimestampExpired(unsigned long timestamp) {
00003a  0001              MOVS     r1,r0
;;;54       unsigned long now = T0TC;
00003c  4812              LDR      r0,|L1.136|
00003e  3840              SUBS     r0,r0,#0x40
000040  6882              LDR      r2,[r0,#8]
;;;55     
;;;56       if (now > timestamp)
000042  428a              CMP      r2,r1
000044  d908              BLS      |L1.88|
;;;57       {
;;;58         if ((now - timestamp) < 0x80000000)
000046  1a50              SUBS     r0,r2,r1
000048  2301              MOVS     r3,#1
00004a  07db              LSLS     r3,r3,#31
00004c  4298              CMP      r0,r3
00004e  d201              BCS      |L1.84|
;;;59           return 1;
000050  2001              MOVS     r0,#1
                  |L1.82|
;;;60         else
;;;61           return 0;
;;;62       }
;;;63       else
;;;64       {
;;;65         if ((timestamp - now) >= 0x80000000)
;;;66           return 1;
;;;67         else
;;;68           return 0;
;;;69       }
;;;70     }
000052  4770              BX       lr
                  |L1.84|
000054  2000              MOVS     r0,#0                 ;61
000056  e7fc              B        |L1.82|
                  |L1.88|
000058  1a88              SUBS     r0,r1,r2              ;65
00005a  2301              MOVS     r3,#1                 ;65
00005c  07db              LSLS     r3,r3,#31             ;65
00005e  4298              CMP      r0,r3                 ;65
000060  d301              BCC      |L1.102|
000062  2001              MOVS     r0,#1                 ;66
000064  e7f5              B        |L1.82|
                  |L1.102|
000066  2000              MOVS     r0,#0                 ;68
000068  e7f3              B        |L1.82|
;;;71     
                          ENDP

                  Timer_Delay PROC
;;;72     // pause for a specific number of milliseconds
;;;73     void Timer_Delay(unsigned long milliseconds) {
00006a  b530              PUSH     {r4,r5,lr}
00006c  0004              MOVS     r4,r0
;;;74       unsigned long timestamp = Timer_GetTimestamp() + milliseconds;
00006e  f7fffffe          BL       Timer_GetTimestamp
000072  1905              ADDS     r5,r0,r4
;;;75       while (!Timer_HasTimestampExpired(timestamp));
000074  46c0              MOV      r8,r8
                  |L1.118|
000076  0028              MOVS     r0,r5
000078  f7fffffe          BL       Timer_HasTimestampExpired
00007c  2800              CMP      r0,#0
00007e  d0fa              BEQ      |L1.118|
;;;76     }
000080  bc30              POP      {r4,r5}
000082  bc08              POP      {r3}
000084  4718              BX       r3
                          ENDP

000086  0000              DCW      0x0000
                  |L1.136|
                          DCD      0xe0004040
                  |L1.140|
                          DCD      0x00002edf
